﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MoneyWentWhere.WinFormsUI
{
    public partial class InputBox : Form
    {
        public InputBox()
        {
            InitializeComponent();
        }

        private void bOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        public static DialogResult ShowDialog(
            String title, String prompt, ref String value)
        {
            InputBox ib = new InputBox();
            ib.Text = title;
            ib.lbPrompt.Text = prompt;
            ib.tValue.Text = value;

            DialogResult dr = ib.ShowDialog();
            if (dr == DialogResult.OK)
            {
                value = ib.tValue.Text;
            }
            else
            {
                value = null;
            }
            return dr;
        }

        public static String GetText(String title, String prompt)
        {
            String value = null;
            ShowDialog(title, prompt, ref value);
            return value;
        }
    }
}
